# _*_ coding utf-8 _*_
# FILENAME：.py
# DESCRIPTION: 资源文件工具类
# AUTH: ZB
# DATE: 2022/6/2 10:00 下午

# 导入模块
import configparser
import os
import sys

# 获取ICO
from constant import UploadType


def get_ico():
    return resource_path(os.path.join("drp.ico"))


# 生成资源文件目录访问路径
def resource_path(relative_path):
    if getattr(sys, 'frozen', False):  # 是否Bundle Resource
        base_path = sys._MEIPASS
    else:
        base_path = os.path.abspath(".")
    return os.path.join(base_path, relative_path)


# 获取excel模版路径
def get_excel_path(type):
    base_path = "assets/excel/"
    if type == UploadType.BOM.value:
        path = resource_path(base_path + "BOM模版.xlsx")
    elif type == UploadType.PRODUCE_SPEED.value:
        path = resource_path(base_path + "生产速度模版.xlsx")
    elif type == UploadType.PRODUCE_QUEUE.value:
        path = resource_path(base_path + "生产队列模版.xlsx")
    elif type == UploadType.PARTS.value:
        path = resource_path(base_path + "零件基础信息模版.xlsx")
    elif type == UploadType.PARTS_LOAD_DELAY_TIME.value:
        path = resource_path(base_path + "零件装配延误时间模版.xlsx")
    elif type == UploadType.INVENTORY.value:
        path = resource_path(base_path + "现有库存模版.xlsx")
    elif type == UploadType.SHIPPER.value:
        path = resource_path(base_path + "承运商信息模版.xlsx")
    elif type == UploadType.OPERATION_TIME.value:
        path = resource_path(base_path + "作业时间模版.xlsx")
    elif type == UploadType.FACTORY_TRANSPORT_TIME.value:
        path = resource_path(base_path + "厂内运行时间模版.xlsx")
    elif type == UploadType.SUPPLIER_DISTANCE.value:
        path = resource_path(base_path + "供应商距离模版.xlsx")
    elif type == UploadType.SUPPLIER_DURATION.value:
        path = resource_path(base_path + "供应商路程时间模版.xlsx")
    elif type == UploadType.SUPPLIER.value:
        path = resource_path(base_path + "供应商地址模版.xlsx")
    elif type == UploadType.REQUIRE.value:
        path = resource_path(base_path + "零件需求模板.xlsx")
    else:
        return
    return path
